package router

import (
	"github.com/gin-gonic/gin"
	"wechat_1004/internal/middleware"
	"wechat_1004/internal/service"
)

func Router(r *gin.Engine) {
	api := r.Group("/api")
	{
		//图片上传
		r.POST("upload", service.UploadFile)
		//短信发送
		r.POST("sendSms", service.SendSms)
		//用户
		user := api.Group("/user")
		{
			//注册
			user.POST("register", service.RegisterUser)
			//登录
			user.POST("login", service.LoginUser)
			user.Use(middleware.Auth())
			//设置微信号
			user.POST("update", service.UpdateUser)
		}

		//通讯录
		contact := api.Group("/contact")
		{
			//添加联系人
			contact.POST("add", service.AddContact)
			//同步通讯录
			contact.GET("findList", service.FindListContact)
		}

		//聊天
		chat := api.Group("/chat")
		{
			//发送消息
			chat.GET("ws", service.Chat)
			//获取聊天记录
			chat.GET("findMessage", service.FindMessageChat)
			//撤回消息
			chat.POST("delete", service.DeleteMessage)
		}
		//朋友圈
		moments := api.Group("/moments")
		{
			//发布动态
			moments.POST("add", service.AddMoment)
			//查看动态
			moments.GET("findMoment", service.FindMoment)
		}
	}
}
